/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package exercises.day02.pt01;

/**
 *
 * @author (jaice)
 * @version 0.1 (may 28, 2012)
 * 
 * c. Design and implement a class called Card that represents a standard
 * playing card. Each card has a suit and a face value. Create a class called
 * DeckOfCards that stores 52 objects of the Card class. Include methods to shuffle
 * the deck, deal a card, and report the number of cards left in the deck. The shuffle 
 * method should assume a full deck. Create a test class with a main method that deals 
 * each card from a shuffled deck, printing each card as it is dealt.
 * 
 * 
 */
public class Card {

    public final  int SPADES = 0, // Codes for the 4 suits.
            HEARTS = 1,
            DIAMONDS = 2,
            CLUBS = 3;
    public final  int ACE = 1, // Codes for the non-numeric cards.
            JACK = 11, //   Cards 2 through 10 have their 
            QUEEN = 12, //   numerical values for their codes.
            KING = 13;
    private final int suit;   // The suit of this card, one of the constants
    //    SPADES, HEARTS, DIAMONDS, CLUBS.
    private final int value;  // The value of this card, from 1 to 11.

    public Card(int theValue, int theSuit) {
        // Construct a card with the specified value and suit.
        value = theValue;
        suit = theSuit;
    }

    public int getSuit() {
        // Return the int that codes for this card's suit.
        return suit;
    }

    public int getValue() {
        // Return the int that codes for this card's value.
        return value;
    }

    public String getSuitAsString() {
        // Return a String representing the card's suit.
        // (If the card's suit is invalid, "??" is returned.)
        switch (suit) {
            case SPADES:
                return "Spades";
            case HEARTS:
                return "Hearts";
            case DIAMONDS:
                return "Diamonds";
            case CLUBS:
                return "Clubs";
            default:
                return "??";
        }
    }

    public String getValueAsString() {
        // Return a String representing the card's value.
        // If the card's value is invalid, "??" is returned.
        switch (value) {
            case 1:
                return "Ace";
            case 2:
                return "2";
            case 3:
                return "3";
            case 4:
                return "4";
            case 5:
                return "5";
            case 6:
                return "6";
            case 7:
                return "7";
            case 8:
                return "8";
            case 9:
                return "9";
            case 10:
                return "10";
            case 11:
                return "Jack";
            case 12:
                return "Queen";
            case 13:
                return "King";
            default:
                return "??";
        }
    }

    public String toString() {
        // Return a String representation of this card
        return getValueAsString() + " of " + getSuitAsString();
    }
}
